package com.qfmy.app.controller.novel;

import com.qfmy.app.service.novel.BookSelfService;
import com.qfmy.app.vo.novel.BookSelfVo;
import com.qfmy.common.result.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.app.controller.novel
 * @date 2025/4/15
 * @description 书架
 */
@RestController
@RequestMapping("/app/bookSelf")
@SuppressWarnings("all")
public class BookSelfController {

    /**
     * 注入service
     */
    @Resource
    private BookSelfService bookSelfService;

    /**
     * 分页获取所有的小说
     */
    @RequestMapping("/getAll")
    public Result<List<BookSelfVo>> getAll(@RequestParam int pageNum, @RequestParam int size) {
        List<BookSelfVo> list = bookSelfService.getAll(pageNum, size);
        return Result.ok(list);
    }

    /**
     * 根据id删除阅读记录
     */
    @RequestMapping("/deleteBookSelfById")
    public Result deleteBookSelfById(@RequestParam Integer id) {
        bookSelfService.deleteBookSelfById(id);
        return Result.ok();
    }

    /**
     * 加入书架
     */
    @RequestMapping("/addBookSelf")
    public Result addBookSelf(@RequestParam Integer bookId) {
        bookSelfService.addBookSelf(bookId);
        return Result.ok();
    }



}
